﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace _03_Quadronacci
{
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger first = BigInteger.Parse(Console.ReadLine());
            BigInteger second = BigInteger.Parse(Console.ReadLine());
            BigInteger third = BigInteger.Parse(Console.ReadLine());
            BigInteger fourth = BigInteger.Parse(Console.ReadLine());
            int r = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            BigInteger currentQadronacci;
            for (int i = 1; i <= r; i++)
            {
                for (int j = 1; j <= c; j++)
                {
                    switch (j + (i - 1) * c)//current Quadronacci index
                    {
                        case 1: currentQadronacci = first; break;
                        case 2: currentQadronacci = second; break;
                        case 3: currentQadronacci = third; break;
                        case 4: currentQadronacci = fourth; break;
                        default: currentQadronacci = first + second + third + fourth;
                                 first = second;
                                 second = third;
                                 third = fourth;
                                 fourth = currentQadronacci;break;
                    }                                       
                    if (j==c)
                    {
                        Console.Write(currentQadronacci);
                    }
                    else
                    {
                        Console.Write("{0} ",currentQadronacci);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}
